<template>
    <div>
        <!-- 修改部门 -->
        <el-form :model="formDate" ref="form" label-width="80px" :inline="false">
            <el-row>
                <el-col :span="24">
                    <el-form-item label="上级部门">
                        <el-tree-select v-model="formDate.parentId" :data="treeData" check-strictly node-key="deptId"
                            :props="{ label: 'deptName', children: 'children' }" placeholder="请选择上级部门"
                            :render-after-expand="false" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="12">
                    <el-form-item label="部门名称">
                        <el-input v-model="formDate.deptName"></el-input>
                    </el-form-item></el-col>
                <el-col :span="12"> <el-form-item label="显示排序">
                        <el-input-number v-model="formDate.orderNum" :min="0" :max="1000" controls-position="right"
                            size="large" @change="handleChange" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="12">
                    <el-form-item label="负责人">
                        <el-input v-model="formDate.leader"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="联系电话">
                        <el-input v-model="formDate.phone"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="12">
                    <el-form-item label="邮箱">
                        <el-input v-model="formDate.email"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="部门状态">
                        <el-radio-group v-model="formDate.status">
                            <el-radio value="0">正常</el-radio>
                            <el-radio value="1">停用</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">立即修改</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script setup>
import { defineEmits, defineProps, ref, onMounted } from 'vue';
import request from "@/api/request";
let emits = defineEmits(['close'])
let props = defineProps(['data'])

let formDate = props.data
//排序框
const handleChange = (value) => {
    console.log(value)
}

let onSubmit = () => {
    // console.log(parentId.value)
    // console.log(formDate)
    request.put("slm/dept/update", formDate).then(resp => {
        emits('close')
    })
}

// 定义响应式数据
let treeData = ref([]);
onMounted(() => {
    request({
        url: '/slm/dept/findD',
        method: 'get',
        params: {}
        // ,
        // headers: "Content-Type: application/json"
    }).then(resp => {
        console.log(resp.data)
        treeData.value = resp.data;
        // treeData.value = transformTreeData(rawData)
    })
})

</script>

<style lang='scss' scoped></style>
